import util from './util.js'
//登录
const login = ({code}) => {
  return util.getApi({
    method: 'POST',
    action: '/account/login',
    data: { code },
  });
};

//完善资料
const complete = ({ nickName, headImg, phone, agent }) => {
  return util.getApi({
    method: 'POST',
    action: '/account/complete',
    data: { nickName, headImg, phone, agent },
  });
};

//幻灯片/地区
const jobLayer = () => {
  return util.getApi({
    method: 'GET',
    action: '/job/layer',
  });
};

//职位列表
const jobSearch = ({ searchKey, region, orderBy, pageIndex, pageSize}) => {
  return util.getApi({
    method: 'POST',
    action: '/job/search',
    data: { searchKey, region, orderBy, pageIndex, pageSize }
  });
};

//职位列表
const jobDetail = (eid) => {
  return util.getApi({
    method: 'GET',
    action: `/job/detail/${eid}`
  });
};

//报名
const jobApply = (eid) => {
  return util.getApi({
    method: 'POST',
    action: `/job/apply`,
    data: { eid }
  });
};

//团队首页
const teamDashboard = () => {
  return util.getApi({
    method: 'GET',
    action: '/team/dashboard',
  });
};

//个人中心首页
const personalHome = () => {
  return util.getApi({
    method: 'GET',
    action: '/personal/home',
  });
};

//查询实名信息
const personalQueryrealinfo = () => {
  return util.getApi({
    method: 'GET',
    action: '/personal/query-real-info',
  });
};

//绑定实名信息
const personalBindrealinfo = (data) => {
  return util.getApi({
    method: 'POST',
    action: '/personal/bind-real-info',
    data: data
  });
};

//提现操作单位
const personalWithdrawalunit = () => {
  return util.getApi({
    method: 'GET',
    action: '/personal/withdrawal-unit'
  });
};

//提现
const personalWithdrawal = ({ amount }) => {
  return util.getApi({
    method: 'POST',
    action: '/personal/withdrawal',
    data: { amount }
  });
};

//申请经纪人
const applyAgent = () => {
  return util.getApi({
    method: 'PUT',
    action: '/personal/apply-agent'
  });
};

//规则说明
const teamRule = () => {
  return util.getApi({
    method: 'GET',
    action: '/team/rule'
  });
};

//我的直推经纪人(审核用)
const teamMembers = () => {
  return util.getApi({
    method: 'GET',
    action: `/team/members`
  });
};

//审核直推经纪人
const teamAuditMembers = ({memberId,allow,remark}) => {
  return util.getApi({
    method: 'POST',
    action: '/team/audit-member',
    data: {memberId,allow,remark}
  });
};

//我的团队成员
const teamChildren = ({type,pageIndex,pageSize}) => {
  return util.getApi({
    method: 'GET',
    action: `/team/children/${type}/${pageIndex}/${pageSize}`
  });
};

//修改手机号
const modifyPhone = ({phone}) => {
  return util.getApi({
    method: 'POST',
    action: '/personal/modify-phone',
    data: {phone}
  });
};

//提现操作单位
const withdrawalunit = () => {
  return util.getApi({
    method: 'GET',
    action: '/personal/withdrawal-unit'
  });
};

//绑定支付宝信息
const bindAlipay = ({ alipayName, alipayAccount }) => {
  return util.getApi({
    method: 'POST',
    action: '/personal/bind-alipay',
    data: { alipayName, alipayAccount }
  });
};

//财富变化记录
const wealthHistory = () => {
  return util.getApi({
    method: 'GET',
    action: '/personal/wealth-history'
  });
};


module.exports = {
  login, complete, jobLayer, jobSearch, teamDashboard, personalHome, personalQueryrealinfo,
  personalBindrealinfo, personalWithdrawalunit, personalWithdrawal, applyAgent, teamRule, jobDetail,
  jobApply, teamMembers, teamAuditMembers, teamChildren, modifyPhone, withdrawalunit, bindAlipay, wealthHistory
}